home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / lisp / kcl / akcl / akcl1615.lha / h / mc68k.h < prev    next >
C/C++ Source or Header  |  1992-02-04  |  2KB  |  92 lines

  1.  
  2. #ifdef __GNUC__
  3. /* so have assembler macros */
  4.  
  5. /* divul
  6.    rem=hl; f=divul(x,y,rem);
  7.          then
  8.    hl:x == f*y + rem  is true */
  9.  
  10. #define divul(x,y,hiremainder) \
  11. ({ulong __x =(x),__y=(y); \
  12.   asm volatile("divul %3,%1:%0" \
  13.      :"=d" (__x),"=d" (hiremainder) \
  14.      :"0" (__x),"dmn"(__y),"1" (hiremainder) );  \
  15.    __x;})
  16.  
  17.  
  18. /*    mulul is a macro:
  19.     f = mulul(a,b,h) <--> h:f  == a*b
  20. */
  21.  
  22. #define mulul(x,y,hiremainder) \
  23. ({ulong __x =(x),__y=(y); \
  24.   asm volatile("mulul %3,%1:%0" \
  25.      :"=d" (__x),"=d" (hiremainder) \
  26.      :"0" (__x),"dmn"(__y),"1" (hiremainder) );  \
  27.    __x;})
  28.  
  29.  
  30.   /* add_carry: add X and Y  adding 1 to H if there was overflow
  31.      H is presumed to be small enough not to overflow 
  32.      */
  33. #define ZERO 0
  34. /* note we have to pass the dummy arg (__res) to addxl asm,
  35.    to force that addition to take first */
  36. #define add_carry(x,y,h) \
  37. ({ulong __res ; \
  38.   __res = (x) + (y); \
  39.      asm volatile("addxl %2,%0" \
  40.   :"=d" (h): "0" (h) , "d" (ZERO),"d" (__res)); \
  41.     __res;})
  42.  
  43.  
  44.   /* SET_MACHINE_CARRYSet the machine carry flag
  45.      if  overflow = 1 other wise clear it.
  46.    */
  47.  
  48. #define SET_MACHINE_CARRY(overflow) \
  49.   asm volatile("addl #-1,%0" : "=d" (overflow) : "0" (overflow))
  50.  
  51.  
  52.   /* SET_OVERFLOW Set the overflow = the current carry code
  53.      Note that machine loads and mov's should not affect
  54.      the carry code. 
  55.    */
  56.  
  57. #define SET_OVERFLOW \
  58.   asm volatile("clrl %0\n\taddxl %0,%0" \
  59.   : "=d" (overflow))
  60.  
  61. /* x - y */
  62. #define SUBXCC(xp,yp)\
  63. ({unsigned long _res;  asm volatile("subxl %2,%0" \
  64.   :"=d" (_res): "0" (xp) , "d" (yp)); _res;})
  65.  
  66. #define ADDXCC(xp,yp)\
  67. ({unsigned long _res;  asm volatile("addxl %2,%0" \
  68.   :"=d" (_res): "0" (xp) , "d" (yp)); _res;})
  69.  
  70. /* The 'X' bit of the condition code won't be
  71.    affected by computing the jump label */
  72.  
  73. #define C_SWITCH_DOESNT_AFFECT_CARRY
  74.  
  75. /* index of the first non zero bit numbering from left */
  76.  
  77. #define bfffo(x) \
  78. ({ulong _res;  asm ("bfffo %1{#0:#0},%0" : "=d" (_res): "rm" (x)); _res;})
  79.  
  80. #define NEED_MULUL3
  81. #define NEED_DIVUL3
  82.  
  83.      
  84. #else  /* not gcc */
  85.  
  86. #endif
  87.      
  88.  
  89.  
  90.   
  91. #define BASE_COUNTER -1   
  92.